import React, { Component ,Suspense} from 'react'
import { connect } from 'react-redux'
import './App.css';

import RouterView from './router/RouterView';
import routerConfig from './router/routerConfig';
import {getListData} from './store/action'
interface Props {
  getList():void
}
interface State {
  
}

export class App extends Component<Props, State> {
  state = {}
  async componentDidMount(){
    await this.props.getList()
  }
  render() {
    return (
      <div className='App'>
        <Suspense fallback={<div>Loading...路由比较懒,不要着急哦</div>}>
            <RouterView routes={routerConfig}/>
        </Suspense>
      </div>
    )
  }
}


const mapDispatchToProps = (dispatch:Function)=>({
  getList:()=>dispatch(getListData())
})

export default connect(null, mapDispatchToProps)(App)
